package com.eatme.core.design.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

public class PromotionStrategyFactory {
    private static Map<String,PromotionStrategy> PROMOTION_STRATEGY_MAP = new HashMap<String,PromotionStrategy>();
    static  {

        PROMOTION_STRATEGY_MAP.put("LIJIAN",new LiJianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put("FANXIAN",new FanXianPromotionStrategy());
        PROMOTION_STRATEGY_MAP.put("MANJIAN",new ManJianPromotionStrategy());

    }

    private static final PromotionStrategy NON_PROMOTION_STRATEGY = new EmptyPromotionStrategy();

    private PromotionStrategyFactory() {

    }
    public static PromotionStrategy getPromotionStrategy(String promotionKey) {
        PromotionStrategy promotionStrategy = PROMOTION_STRATEGY_MAP.get(promotionKey);
        return promotionStrategy == null?NON_PROMOTION_STRATEGY : promotionStrategy;
    }

    private interface  PromotionKey {

        String LIJIAN = "LIJIAN";

        String FANXIAN = "FANXIAN";

        String MANJIAN = "MANJIAN";

    }

}
